package com.seteam.collabcrossword;

import com.seteam.collabcrossword.exceptions.CollabCrosswordException;

import java.io.Serializable;

/**
 * This class is a wrapper around two integers. It represents the x and y coordinates
 * of a given tile on a board
 */
public class Coordinates implements Serializable {
    private static final long serialVersionUID = 6652490777155243501L;
    private int xCoordinate;
    private int yCoordinate;

    /**
     * Constructor
     */
    public Coordinates() {
        //If there is a need to create a coordinates object
        //and set the values later
    }

    /**
     * Constructor
     *
     * @param xCoordinate the x coordinate
     * @param yCoordinate the y coordinate
     * @throws CollabCrosswordException if either of the passed values are negative
     */
    public Coordinates(final int xCoordinate, final int yCoordinate) throws CollabCrosswordException {
        CollabCrosswordUtils.isPositive(xCoordinate, Globals.COORDINATES_ERROR +
                "xCoordinate cannot be negative");
        CollabCrosswordUtils.isPositive(yCoordinate, Globals.COORDINATES_ERROR +
                "yCoordinate cannot be negative");
        this.xCoordinate = xCoordinate;
        this.yCoordinate = yCoordinate;
    }

    /**
     * Getter for xCoordinate
     *
     * @return the x-coordinate
     */
    public int getxCoordinate() {
        return xCoordinate;
    }

    /**
     * Setter for xCoordinate
     *
     * @param xCoordinate the value to be set
     */
    public void setxCoordinate(final int xCoordinate) {
        this.xCoordinate = xCoordinate;
    }

    /**
     * Getter for yCoordinate
     *
     * @return the y-coordinate
     */
    public int getyCoordinate() {
        return yCoordinate;
    }

    /**
     * Setter for yCoordinate
     *
     * @param yCoordinate the value to be set
     */
    public void setyCoordinate(final int yCoordinate) {
        this.yCoordinate = yCoordinate;
    }


}
